from paddleocr import PaddleOCR
import os
os.environ['LOGLEVEL'] = 'ERROR'  # 关闭DEBUG日志
import sys
import json

ocr = PaddleOCR(use_angle_cls=True, lang="ch", show_log=False)

def recognize(image_path):
    result = ocr.ocr(image_path, cls=True)
    texts = [line[1][0] for line in result[0]]
    return {"text": "\n".join(texts)}

if __name__ == "__main__":
    print(json.dumps(recognize(sys.argv[1])))